home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Moscow ML 1.42 / lib / Lexing.sig < prev    next >
Encoding:
Text File  |  1997-08-18  |  3.6 KB  |  80 lines  |  [TEXT/Moml]

  1. (* Internal run-time library for lexers generated by mosmllex.
  2.  * Closely based on the library for camllex.  Copyright 1993 INRIA, France. 
  3.  *)
  4.  
  5. local open Obj in
  6.  
  7. (*** Lexer buffers *)
  8.  
  9. type lexbuf;
  10.         (* The type of lexer buffers. A lexer buffer is the argument passed
  11.            to the scanning functions defined by the generated scanners.
  12.            The lexer buffer holds the current state of the scanner, plus
  13.            a function to refill the buffer from the input. *)
  14.  
  15. prim_val getLexBuffer     : lexbuf -> string           = 1 "field1";
  16. prim_val getLexAbsPos     : lexbuf -> int              = 1 "field2";
  17. prim_val getLexStartPos   : lexbuf -> int              = 1 "field3";
  18. prim_val getLexCurrPos    : lexbuf -> int              = 1 "field4";
  19. prim_val getLexLastPos    : lexbuf -> int              = 1 "field5";
  20. prim_val getLexLastAction : lexbuf -> (lexbuf -> obj)  = 1 "field6";
  21.  
  22. prim_val setLexAbsPos     : lexbuf -> int -> unit             = 2 "setfield2";
  23. prim_val setLexStartPos   : lexbuf -> int -> unit             = 2 "setfield3";
  24. prim_val setLexCurrPos    : lexbuf -> int -> unit             = 2 "setfield4";
  25. prim_val setLexLastPos    : lexbuf -> int -> unit             = 2 "setfield5";
  26. prim_val setLexLastAction : lexbuf -> (lexbuf -> obj) -> unit = 2 "setfield6";
  27.  
  28. val createLexerString : string -> lexbuf;
  29.         (* Create a lexer buffer which reads from
  30.            the given string. Reading starts from the first character in
  31.            the string. An end-of-input condition is generated when the
  32.            end of the string is reached. *)
  33.  
  34. val createLexer : (CharArray.array -> int -> int) -> lexbuf;
  35.         (* Create a lexer buffer with the given function as its reading method.
  36.            When the scanner needs more characters, it will call the given
  37.            function, giving it a character string [s] and a character
  38.            count [n]. The function should put [n] characters or less in [s],
  39.            starting at character number 0, and return the number of characters
  40.            provided. A return value of 0 means end of input. *)
  41.  
  42. (*** Functions for lexer semantic actions *)
  43.  
  44.         (* The following functions can be called from the semantic actions
  45.            of lexer definitions (the ML code enclosed in braces that
  46.            computes the value returned by lexing functions). They give
  47.            access to the character string matched by the regular expression
  48.            associated with the semantic action. These functions must be
  49.            applied to the argument [lexbuf], which, in the code generated by
  50.            camllex, is bound to the lexer buffer passed to the parsing
  51.            function. *)
  52.  
  53. val getLexeme : lexbuf -> string;
  54.         (* [getLexeme lexbuf] returns the string matched by
  55.            the regular expression. *)
  56.  
  57. val getLexemeChar : lexbuf -> int -> char;
  58.         (* [getLexemeChar lexbuf i] returns character number [i] in
  59.            the matched string. *)
  60.  
  61. val getLexemeStart : lexbuf -> int;
  62.         (* [getLexemeStart lexbuf] returns the position in the input stream
  63.            of the first character of the matched string. The first character
  64.            of the stream has position 0. *)
  65.  
  66. val getLexemeEnd : lexbuf -> int;
  67.         (* [getLexemeEnd lexbuf] returns the position in the input stream
  68.            of the character following the last character of the matched
  69.            string. The first character of the stream has position 0. *)
  70. (*--*)
  71.  
  72. (* The following definitions are used by the generated scanners only.
  73.    They are not intended to be used by user programs. *)
  74.  
  75. val dummyAction : lexbuf -> obj;
  76. prim_val getNextChar : lexbuf -> char = 1 "get_next_char";
  77. val backtrack : lexbuf -> 'a;
  78.  
  79. end;
  80.